import Mock from 'mockjs'
import { Message } from './msg1'
// import * as test from 'es-toolkit'
const template = {
  cc: true,
  'flow|1': ['out', 'in'],
  'from|1': /cs\d{1}/,
  'fromClientType|1': ['Web', 'Android', 'IOS'],
  'fromDeviceId|1': ['2fb0d8c26d874a4790a92719a186bea0', '3ab0ddc2rtjk4a4790a92719o98jbAa1', '4ab0ddc2rtjk4a4790a92719o98jbAa1'],
  'fromNick|1': /nick\d{1}/,
  idClient: /\w{32}/,
  idServer: /\d{12}/,
  isHistoryable: true,
  isLocal: false,
  isOfflinable: true,
  isPushable: true,
  isReplyMsg: true,
  isRoamingable: true,
  isSyncable: true,
  isUnreadable: true,
  needMsgReceipt: false,
  needPushNick: true,
  resend: false,
  scene: 'p2p',
  // sessionId: /p2p-cs\d{1}/,
  'sessionId|1': ['p2p-cs1', 'p2p-cs2', 'p2p-cs3'],
  status: 'success',
  'target|1': /cs\d{1}/,
  text: Mock.Random.cparagraph(2, 10),
  'time|1577836800000-1625097600000': 1,
  'to|1': /cs\d{1}/,
  type: 'text',
  'userUpdateTime|1600000000000-1700000000000': 1,
  // 'content': '{"type":"1","value":{"id":"p2p-cjhz2","msgReceiptTime":1624606039842,"scene":"p2p","to":"cjhz2","updateTime":1624873356674,"lastMsg":{"scene":"p2p","from":"cjhz1","fromNick":"cjhz1","fromClientType":"Web","fromDeviceId":"29d79b4e7a1267af0e66bd46e4f1bc13","to":"cjhz2","time":1624873356674,"type":"custom","text":"","isHistoryable":true,"isRoamingable":true,"isSyncable":true,"cc":true,"isPushable":true,"isOfflinable":true,"isUnreadable":true,"isReplyMsg":true,"needPushNick":true,"needMsgReceipt":false,"isLocal":false,"resend":false,"idClient":"c39b620b46724757c8211456a8b5b0ae","idServer":"10072097","userUpdateTime":1624608239948,"callbackExt":"123456abcd","status":"success","content":"{\"type\":1,\"data\":{\"value\":2}}","target":"cjhz2","sessionId":"p2p-cjhz2","flow":"out"},"unread":2}}'
  content: ''
}

export function generateMessage(text = ''): Message {
  const temp = Mock.mock(template)
  temp.text = text + Mock.Random.cparagraph(2, 10)
  return temp
}
